import xlrd
wt=xlrd.open_workbook(filename="baidu员工人员信息.xls")
st=wt.sheet_by_index(0)

def count(*args): # args用元组接受数据
    sum=0
    for a in args:
        for x in st.col_values(5)[1:]:
            if x.startswith(a):
                sum+=1
            else:
                continue
    return sum
def sexsum(sexb):
    sex=st.col_values(8)
    ssum=0
    for se in sex:
        if se==sexb:
            ssum+=1
        else:
            continue
    return ssum
def oldsum(age):
    s=0
    for e in st.col_values(7)[1:]:
        if e>45:
            s+=1
        else:
            continue
    return s
def chuanmei():
    s=0
    for x in st.col_values(13):
        if "传媒" in x:
            s+=1
        else:
            continue
    return s
def yiqing(*args):
    s=0
    for x in args:
        for y in st.col_values(9)[1:]:
            if x in y:
                s+=1
            else:
                continue
    return  s
def xingzigao(number):
    s=0
    for x in st.col_values(11)[1:]:
        if x>=number:
            s+=1
        else:
            continue
    return s
def xingzidi(number):
    s=0
    for x in st.col_values(11)[1:]:
        if x<=number:
            s+=1
        else:
            continue
    return s

print("表格中的人数：",st.nrows-1)
dianxing= count("133","149","153","173","177","180","181","189","1700","1701","1702")
print("电信用户数量：",dianxing,"占比为:","%.2f"%((dianxing/(st.nrows-1))*100),"%")
yidong= count("134","135","136","137","138","139","147","150","151","152","157","158","159","178","182","183","184","187","188","1703","1705","1706")
print("移动用户数量：",yidong,"占比为:","%.2f"%((yidong/(st.nrows-1))*100),"%")
laintong= count("130","131","132","145","155","156","175","176","185","186","1704","1707","1708","1709","171")
print("联通用户数量：",laintong,"占比为:","%.2f"%((laintong/(st.nrows-1))*100),"%")

print("男人：",sexsum("男"),"女人：",st.nrows-1-sexsum("男"))

print("年龄大于45的员工人数：",oldsum(45))

print("薪资高于8000的人数：",xingzigao(8000)," 薪资低于3000人数：",xingzidi(3000))

print("传媒公司人数为：",chuanmei())

print("疫情高危地区人数：",yiqing("黑龙江","北京","福建","四川"))

